package com.ys.service.amazonorder.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ys.mapper.amazonorder.AmazonorderMapper;
import com.ys.service.amazonorder.TpAmazonShopOrderDailyService;

@Service("tpAmazonShopOrderDailyService")
public class TpAmazonShopOrderDailyServiceImpl implements TpAmazonShopOrderDailyService {

    private static final Logger logger = LoggerFactory.getLogger(TpAmazonShopOrderDailyServiceImpl.class);

	@Autowired
	private AmazonorderMapper amazonorderMapper;

	@Override
	public void addBatch(String day) {
		if (day == null || day.length() != 10) {
			return;
		}
		
		// 删除每日数据
		amazonorderMapper.deleteBatchTpAmazonShopOrderDailyByDay(day);
		
		// 添加每日数据
		int i = amazonorderMapper.insertBatchTpAmazonShopOrderDailyByDay(day);
		logger.info("日期---" + day + "，添加数量---" + i);
	}

	@Override
	public void updateCount(String day) {
		int i = amazonorderMapper.updateCountTpAmazonShopOrderDailyByDay(day);
		logger.info("日期---" + day + "，更新数量---" + i);
	}

	@Override
	public void updateCountByDayAndSeller(String day, String sellerId) {
		int i = amazonorderMapper.updateCountTpAmazonShopOrderDailyByDayAndSeller(day, sellerId);
		logger.info("日期---" + day + "，卖家---" + sellerId + "，更新数量---" + i);
	}

	@Override
	public void addBatchBySeller(String day, String sellerId) {
		if (day == null || day.length() != 10) {
			return;
		}
		
		// 删除每日数据
		amazonorderMapper.deleteBatchTpAmazonShopOrderDailyByDayAndSeller(day, sellerId);
		
		// 添加每日数据
		int i = amazonorderMapper.insertBatchTpAmazonShopOrderDailyByDayAndSeller(day, sellerId);
		logger.info("日期---" + day + "，卖家---" + sellerId + "，添加数量---" + i);
	}
}
